#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#__email__ = "wjx010107@163.com"
#__author__ = "weijinxing"

from django.contrib.auth.models import User,Group
from django.shortcuts import render_to_response
from api_salt import saltAPI
from atsystem.settings import GROUPPATH
import yaml,time
from atsystem.models import Mgroup,Calendar,Minions
from djcelery.models import PeriodicTask


def U_count():
    u_count= User.objects.count()
    return u_count

def G_count():
    g_count= Group.objects.count()
    return g_count

def T_count():
    t_count= PeriodicTask.objects.count()
    return t_count


def M_count():
#    sapi = saltAPI()
#    params = {'client':'local', 'fun':'test.ping', 'tgt':'*'}
#    res = sapi.saltCmd(params)
#    return len(res[0].values())

    m_count=Minions.objects.count()
    return m_count


def MG_count():
#    stream1=open(GROUPPATH)
#    resyaml=yaml.load(stream1)
#    stream1.close()
#    return len(resyaml['nodegroups'].keys())
    return Mgroup.objects.count()


